<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head th:replace="base::head(~{})"></head>
<body>
	<div class="x-body layui-anim layui-anim-up">
		<fieldset class="layui-elem-field layui-field-title">
			<legend>新增</legend>
		</fieldset>
		<form id="form" class="layui-form layui-form-pane" action="">
			<div class="layui-form-item">
				<label class="layui-form-label">角色名称</label>
				<div class="layui-input-inline">
					<input type="text" name="nameZh" lay-verify="required" autocomplete="off" placeholder="请输入角色名称" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">说明</label>
				<div class="layui-input-inline">
					<input type="text" name="comment" lay-verify="required" autocomplete="off" placeholder="请输入说明" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item" pane="" style="width: 297px;">
				<label class="layui-form-label">状态</label>
				<div class="layui-input-block">
					<input type="radio" name="status" value="0" title="启用" checked="">
					<input type="radio" name="status" value="1" title="禁用">
				</div>
			</div>
			<div class="layui-form-item">
				<button class="layui-btn" lay-submit="" lay-filter="submit">保存</button>
				<a href="javascript:;" id="close" class="layui-btn">关闭</a>
			</div>
		</form>
	</div>
</body>
<script>
	layui.use([ 'form' ], function() {
		var form = layui.form;
		//监听提交
		form.on('submit(submit)', function(data) {
			$.ajax({
				//几个参数需要注意一下
				type : 'post',//方法类型
				dataType : 'json',//预期服务器返回的数据类型
				url : ctxPath + '/system/role/add',//url
				data : $('#form').serialize(),
				success : function(result) {
					if (result.code == 0) {
						admin_close_success_msg('保存成功');
						return;
					} else {
						layer.msg('保存失败。错误信息：' + result.msg, {
							icon : 2
						});
						return;
					}
				},
				error : function() {
					layer.msg('保存失败', {
						icon : 2
					});
				}
			});
			return false;
		});

		$('#close').on('click', function() {
			admin_close_iframe_window();
		});
	});
</script>
</html>